//
//  PNSolidLineView.m
//  LineChart
//
//  Created by apple on 2024/6/13.
//

#import "PNSolidLineView.h"

@interface PNSolidLineView ()
@property (nonatomic, strong) NSString *text;

@end

@implementation PNSolidLineView

- (instancetype)initWithFrame:(CGRect)frame text:(NSString *)text point:(CGPoint)point {
    if (self = [super initWithFrame:frame]) {
        _text = text;
        _point = point;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(self.frame.size.width/2, 0)];
    [path addLineToPoint:CGPointMake(self.frame.size.width/2, self.frame.size.height)];
    path.lineWidth = 1;
    [path closePath];
    [[UIColor redColor] setStroke];
    [path stroke];
    
    UIBezierPath *p2 = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.frame.size.width/2, self.point.y) radius:3 startAngle:0 endAngle:2*M_PI clockwise:NO];
    p2.lineWidth = 1;
    [[UIColor redColor] setFill];
    [p2 fill];
    
    [self.text drawInRect:CGRectMake(15, self.frame.size.height-20, 15, 20) withAttributes:@{
        NSFontAttributeName:[UIFont systemFontOfSize:18],
        NSForegroundColorAttributeName:[UIColor redColor],
    }];
}

@end
